package com.service.Impl;

import com.pojo.Game;
import com.service.GameSer;

import java.util.ArrayList;
import java.util.List;

import static com.util.Vessel.gameDao;

public class GameSerImpl implements GameSer {
    @Override
    public List<Game> queryGame(Game game) {
        List<Game> gameList = new ArrayList<>();
        if (game.getgName().equals("%%") && game.getgCompany().equals("") && game.getgType().equals("") && game.getgYear().equals("")){
            gameList = gameDao.queryGame();
        }else if (game.getgName() != null && game.getgCompany().equals("") && game.getgType().equals("") && game.getgYear().equals("")){
            gameList = queryGameByName(game);
        }else if (game.getgName().equals("%%") && game.getgCompany().equals("") && game.getgType().equals("") && !game.getgYear().isEmpty()){
            gameList = queryGameByYear(game);
        } else if (!game.getgName().equals("%%") && !game.getgCompany().isEmpty() && !game.getgType().isEmpty() && !game.getgYear().isEmpty()) {
            gameList = queryGameByAll(game);
        } else if (game.getgName().equals("%%") && !game.getgCompany().isEmpty() && game.getgType().equals("") && game.getgYear().equals("")) {
            gameList = queryGameByCompany(game);
        } else if (game.getgName().equals("%%") && game.getgCompany().equals("") && !game.getgType().isEmpty() && game.getgYear().equals("")) {
            gameList = queryGameByType(game);
        }
        return gameList;
    }




    @Override
    public int addGame(Game game) {

        return gameDao.addGame(game);
    }

    @Override
    public int delGame(Game game) {
        return gameDao.delGame(game);
    }

    @Override
    public int altGame(Game game) {
        return gameDao.altGame(game);
    }

    @Override
    public List<Game> queryGameByName(Game game) {
        return gameDao.queryGameByName(game);
    }

    @Override
    public List<Game> queryGameByYear(Game game) {
        return gameDao.queryGameByYear(game);
    }

    @Override
    public List<Game> queryGameByType(Game game) {
        return gameDao.queryGameByType(game);
    }

    @Override
    public List<Game> queryGameByCompany(Game game) {
        return gameDao.queryGameByCompany(game);
    }

    @Override
    public List<Game> queryGameByAll(Game game) {
        return gameDao.queryGameByAll(game);
    }

    @Override
    public int haveGame(Game game) {
        return gameDao.haveGame(game);
    }
}
